package com.ladlee.session.impl;

import com.ladlee.session.AbstractSessionManagerStrategy;
import org.springframework.security.web.session.SessionInformationExpiredEvent;
import org.springframework.security.web.session.SessionInformationExpiredStrategy;

import javax.servlet.ServletException;
import java.io.IOException;

/**
 * @Auther: dingchang
 * @Date: 2018/12/25 10:32
 * @Description: 重写默认的session过期策略
 */
public class LadLeeExpiredStrategy extends AbstractSessionManagerStrategy implements SessionInformationExpiredStrategy {

    public LadLeeExpiredStrategy(String expiredSessionUrl) {
        super(expiredSessionUrl);
    }

    @Override
    public void onExpiredSessionDetected(SessionInformationExpiredEvent sessionInformationExpiredEvent) throws IOException, ServletException {
        onSessionInvalid(sessionInformationExpiredEvent.getRequest(),sessionInformationExpiredEvent.getResponse());
    }

    @Override
    public boolean isConcurrency() {
        return true;
    }
}
